package com.wang.controller;

import com.wang.pojo.Users;
import com.wang.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by wang on 2018/5/1.
 */
@Controller
@RequestMapping(value = "/users")
public class UsersController {

    @Autowired
    private UsersService usersService;
    /**
     * 页面跳转
     */
    @RequestMapping("/{page}")
    public String showPage(@PathVariable String page){
        return page;
    }
   /* *//**
     * 添加用户
     *//*
    @RequestMapping("/addUser")
    public String addUser(Users users){
        this.usersService.addUsers(users);
        return "ok";
    }*/
    /**
     * 添加用户
     */
    @RequestMapping("/addUser")
    @ResponseBody
    public String  addUser(@RequestParam(value = "name") String name, @RequestParam(value = "age") Integer age ){
        Users users=new Users(name,age);
        usersService.addUsers(users);
        return "ok";
    }
}
